3.9 [LibraryClasses] Sections

The [LibraryClasses] sections are optional if no library classes are defined for any of the components, or if only EDK modules are used.

Summary

This section defines the [LibraryClasses] tag required for EDK II module INF files, and is new for EDK II extended DSC files. This is a mapping of library class names to the EDK II module instances that provide the library class.

The one or more !include statements may be used within the library class section.

The !include files may contain LibraryClass|Library Instance statements as well as complete Library Class sections.

The library class entry is a formatted string with two fields, separated by the pipe "|" character.

When parsing the DSC file, the precedence rules must be followed.

  1. If a Library Class Instance (INF) is specified in the EDK II [Components] section (INF file's <LibraryClasses> sub-section,) then it will be used.

  2. If not specified in the [Components] section, then the Library Class Instance that is defined in the [LibraryClasses.$(ARCH).$(MODULE_TYPE)] section will be used.

  3. If not specified in the [LibraryClasses.$(ARCH).$(MODULE_TYPE)] section, then the Library Class Instance that is defined in the [LibraryClasses.Common.$(MODULE_TYPE)] section will be used.

  4. If not specified in the [LibraryClasses.Common.$(MODULE_TYPE)] section, then the Library Class Instance that is defined in the [LibraryClasses.$(ARCH)] section will be used.

  5. If not specified in the [LibraryClasses.$(ARCH)] section, then the Library Class Instance that is defined in the [LibraryClasses] Section or [LibraryClasses.Common] section will be used.

  6. It is an error if it has not been specified in one of the above sections.

Prototype

<LibraryClasses>   ::= "[LibraryClasses" [<attribs>] "]" <EOL> <LcStatements>*
<attribs>          ::= <attrs> ["," "LibraryClasses" <attrs>]*
<attrs>            ::= "." <arch> ["." <Edk2ModuleType>]
<LcStatements>     ::= {<MacroDefinition>} {<IncludeStatment>}
                       {<TS> <LcEntry>}
<LcEntry>          ::= <LibraryClassName> <FS> <LibraryInstance> <EOL>
<LibraryClassName> ::= (A-Z)(a-zA-Z0-9)*
<LibraryInstance>  ::= <InfFileName> <EOL>
<InfFileName>      ::= <PATH> <Word> ".inf"

Example

[LibraryClasses.common]
  BaseLib|MdePkg/Library/BaseLib.inf
  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf PcdLib|MdePkg/Library/BasePcdLib/BasePcdLibNull.inf

[LibraryClasses.common.PEI_CORE, LibraryClasses.common.PEIM]
  DEFINE MDIR = MdePkg/Library
  DebugLib|$(MDIR)/PeiReportStatusCode/PeiReportStatusCodeLib.inf

[LibraryClasses.common.UEFI_DRIVER,
  LibraryClasses.common.UEFI_APPLICATION]
  DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf